*     *****************************************************************   *;
*     *****************************************************************   *;
*   File-Name:     CCA_Index_creation.do         				          *;
*   Date:          June 01, 2021                                  	      *;
*   Authors:       Ece Kural and Lisa Dellmuth	   				          *;
*   Input File:    CCA_Index_creation.dta		                          *; 
*   Related paper: International Organizations and Climate Change   	  *; 
*                  Adaptation: A New Dataset for the Social Scientific    *;
*                  Study of Adaptation, 1990–2017 		   				  *;
*     ****************************************************************    *;
*     ****************************************************************    *;

* Stata/IC 15.1
vers 15.1

set more off 
use "/Users/CCA_Index_creation.dta" 

**************************
/*COLLAPSE*/
**************************
global xlist response_no-staff_yes
collapse (sum) $xlist, by (IGO year)
describe 

xtset IGO year 

decode IGO, gen (IGOname)
order IGOname, a (IGO)

***********************************
/*Creating Prioritization variable*/ 
************************************
*Find min and max for unequal
tab unequal 
//min=0, max=36
tab equal
//min=0, max=24 

replace unequal=(unequal/36)
replace equal=(equal/24) 
tab unequal
tab equal
//min=0, max=1
tab IGO if unequal==1
tab equal 
//min=0, max=1
tab IGO if equal==1

replace priority = [(unequal)* 0.5 + (equal)]/response_no if response_no != 0
replace priority=priority*10
replace priority=0 if priority==.

****************************************************
**Creating Timehorizon Variable// 
****************************************************
//the min=0 but the max is different. 
**//rescale to 0-1 
replace onetimeevent=(onetimeevent/24) 
tab onetimeevent
replace seriesofevents=(seriesofevents/26) 
tab seriesofevents 
replace longterm=(longterm/7) 
tab longterm

replace timehorizon= [(onetimeevent) * 0.5 + (seriesofevents) + (longterm) *1.5]/response_no if response_no != 0
tab timehorizon
replace timehorizon=timehorizon*10
replace timehorizon=0 if timehorizon==.

egen maxtime=max(timehorizon)
replace timehorizon=timehorizon/maxtime
tab timehorizon


*************************************
/***Creating Funding variable*/ 
*************************************
replace funding= poolfunds_yes
*min=0, max=17 
tab IGO if funding==17
replace funding=(funding/17)
tab funding

*************************************
***Creating Staffing variable*/ 
************************************* 
replace staffing= staff_yes
tab staffing
*min=0, max=5
tab IGO if staffing==5
replace staffing=(staffing/5)
tab staffing

****************************************************************
***<<<<Index Creation
****************************************************************
gen index=priority+timehorizon+funding+staffing
egen maxindex=max(index)
replace index=(index/maxindex)*100



